package com.abigdreamer.wordpress.ui;

import java.io.File;

import com.abigdreamer.wordpress.newspider.HtmlSpider;
import com.abigdreamer.wordpress.newspider.ThreadTaskProcesser;
import com.zving.framework.xml.XMLElement;
import com.zving.framework.xml.XMLMultiLoader;

/**
 * 
 * @author Darkness
 * @date 2013-6-2 下午05:25:21
 * @website http://www.abigdreamer.com
 * @version V1.0
 */
public class ArticleAnalyProcessor extends ThreadTaskProcesser<ArticleAnaly> {

	HtmlSpider htmlSpider = new HtmlSpider();

	public ArticleAnalyProcessor(ArticleAnaly threadTaskManager) {
		super(threadTaskManager);
	}

	@Override
	protected void doTask(Object tmp) {
		File file = (File) tmp;
		
		XMLMultiLoader loader = new XMLMultiLoader();
		loader.load(file);
		
		XMLElement data = loader.getElements("article.id").get(0);
        String id = data.getText();
        
        XMLElement titledata = loader.getElements("article.title").get(0);
        String text = titledata.getText();
        
        XMLElement urldata = loader.getElements("article.url").get(0);
        String url = urldata.getText();
         
        WordpressArticle article = new WordpressArticle();
        article.setId(id);
        article.setTitle(text);
        article.setUrl(url);
        
        getThreadTaskManager().articles.add(article);
	}

}
